#include "rtos_classes.h"
#include <stdio.h>


//Class Queue
/****STILL NEED TO WORK ON THIS PART****/
template <class nodeType>
Queue<nodeType>::Queue(int NumOfNodes){
    head=tail=NULL;
    size=0;
    nodeType *temp;
    while (size<NumOfNodes){
        temp=new nodeType();
        this->enqueue(temp);
        temp=NULL;
    }
}
template <class nodeType>
Queue<nodeType>::~Queue(){
		//free all the nodes and then destroy the queue	
    delete [] head, tail, size;
}

template <class nodeType>
void Queue<nodeType>::enqueue(nodeType * newNode){
	 if (size<1)
	 {head=newNode;tail=newNode;size++;return;}
	 tail->next=newNode;
	 tail=newNode;	  
	 newNode->next=NULL;
        size++;
        //cout << "enqueue!";
        return;
}

template <class nodeType>
nodeType * Queue<nodeType>::dequeue(){
	node * temp;
	if (this->size == 0|| this->head==NULL){
		//cout << "its empty !";
		return NULL;
	}		
	temp=head;
	head=temp->next;
	temp->next=NULL;
	size--;
	//cout << "dequeue!";
	return temp;
}

template <class nodeType>
int Queue<nodeType>::getsize(){//count number of nodes in the queue
		return size;
}

template <class nodeType>
int Queue<nodeType>::empty(){
		if (size==0)
			 return 1;
		else
			 return 0;
}

/*
//Class Stack

Stack::Stack(int size){
return -1;					  
}

Stack::~Stack(){
return -1;						  
}
int * Stack::pop(){
return -1;	
}
void Stack::push(int * item){
}

BlockedQ();
				 ~BlockedQ();
				 //return total number of blocked PCBs
				 int getSize();
				 //return total number of PCBs in the selected type queue
				 int getSize(int priority);
				 void enqueue(PCB * newpcb, int blockedType);
				 PCB * dequeue(int blockedtype);
				 int empty();
*/
